<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="t_set" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="inventoryListUpSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage(''+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 盘存设置 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="仓库" prop="">
              {{empty}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="盘存方式" prop="">
              {{t_set.set_way}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="开始价格" prop="set_start_code">
              <el-select style='width:100%' v-model="t_set.set_start_code">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_price" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="结束价格" prop="set_end_code">
              <el-select style='width:100%' v-model="t_set.set_end_code">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_price" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="popInventoryTimeAdd('')" type='success' size="mini"><i class='fa fa-plus'></i>增加</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 盘存日期时间 </span>
      </div>
      <el-table :data="s_date">
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="d_date('&CMID4='+scope.row.date_id+'')">删除</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="开始时间" prop="take_begin_date">
          <template slot-scope="scope">
            {{getDateTimeString(scope.row,'take_begin_date')}}
          </template>
        </el-table-column>
        <el-table-column label="提醒时间" prop="take_remind_date">
          <template slot-scope="scope">
            {{getDateTimeString(scope.row,'take_remind_date')}}
          </template>
        </el-table-column>
        <el-table-column label="盘存要求时间" prop="take_demand_date">
          <template slot-scope="scope"> 小时： </template>
        </el-table-column>
      </el-table>
    </el-form>
    <el-dialog :visible.sync="InventoryTimeAddVisible" append-to-body>
      <InventoryTimeAdd v-if="InventoryTimeAddVisible" ref="InventoryTimeAdd" :popparams="popparams"> </InventoryTimeAdd>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import InventoryTimeAdd from "@/views/psi/supplychainmana/InventoryTimeAdd";
  export default {
    name: 'InventoryListUp',
    components: {
      InventoryTimeAdd,
    },
    props: ['popparams'],
    data() {
      return {
        InventoryTimeAddVisible: false,
        InventoryTimeAddValue: null,
        InventoryTimeAddDesc: null,
        vueparams: this.getVUEParams(""),
        t_set: {
          set_way: null,
          set_start_code: null,
          set_end_code: null,
        },
        s_date: [],
        s_price: [],
        s_price: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/WarehouseAction/inventoryListUp?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_date(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/WarehouseAction/d_date?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      inventoryListUpSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/psi/supplychainmana/WarehouseAction/inventoryListUpSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/psi/supplychainmana/VUEF3FC7C5C81C14B7F94A30B8845713AF0?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popInventoryTimeAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.InventoryTimeAddVisible = !this.InventoryTimeAddVisible;
      },
    },
  }
</script>
